package com.shujia.city.dwd

import org.apache.spark.sql.{DataFrame, Dataset, Row, SparkSession}

object DwdGsjRegInvestorMskDay extends SparkTool {
  /**
   * 在run函数中写数据处理的逻辑
   * import spark.implicits._
   * import org.apache.spark.sql.functions._
   */
  override def run(spark: SparkSession, ds: String): Unit = {
    import spark.implicits._
    import org.apache.spark.sql.functions._

    //1、读取数据
    val investor: Dataset[Row] = spark
      .table("ods.ods_t_gsj_reg_investor")
      .where($"ds" === ds)

    //2、处理数据
    val resultDF: DataFrame = investor
      .select(
        upper(md5(concat($"id", expr("'shujia'")))) as "id"
      )

    //3、保存数据
    saveToTable(spark, resultDF, "dwd.dwd_gsj_reg_investor_msk_d", ds)

  }
}
